<template>
	<view class="room-check-page">
		
		<view class="search-con c-flex ">
			<view class="c-flex jc-between gap-5">
				<view class="input-con c-flex jc-start c-item-center ">
					<image :src="remoteImgUrl+'search-icon.png'" style="width: 42rpx;max-height: 42rpx;    margin-right: 12rpx;"></image>
					<input class="uni-input" v-model="lpgUserName" name="text" style="width:72%" confirm-type="search"  placeholder="根据用户名称搜索" @input="onInputChange" />
					<view class="line"></view>
					<text @click="onInputChange">搜索</text>
				</view>
			</view>	
		</view>
		
		<!-- 日期选择 
		<!-- 列表 -->
		<scroll-view scroll-y="true" style="height: 1150rpx;" @scrolltolower="lower">
			<view class="p-list">
				<view class="p-l-item" v-for="(item,i) in list" :key="i" @tap="detailHandler(item)">
					<image  class="checkImg" :src="checkImg(item)">
					<view class="c_title c-flex">
						<view class="circle_first_char">
							{{getFirstSubstr(item.name)}}
						</view>
						<view class="c_title_type">
							<view class="name">{{item.name ||'' }}</view>
							<view class="time">用户电话:{{item.phone || ''}}</view>
						</view>
						<!-- <view class="c-pos-r" @tap="edit(item)">
							<image  class="checkStatus" :src="remoteImgUserUrl+'edit.png'"></image>
							
						</view> -->
					</view>
					<view class="p-content">
						<view class="p-c-item c-flex " >
							<text>用气类型：</text> <text>{{item.type===0?'民用安检':item.type===1?'商业安检':'工业安检'}}</text>
						</view>
						<view class="p-c-item c-flex" >
							<text>用户地址：</text> <text>{{item.street}}{{item.villageName}}{{item.address}}</text>
						</view>
						
										
						
					</view>	
					<view class="btn c-flex jc-end">
						<!-- <view  v-if='item.auditStatus===0 || item.auditStatus===2' class="editBtn c-flex jc-center c-item-center" @tap.stop="edit(item)">
							<image  :src="imgUserUrl+'edit@2x.png'"></image>编辑
						</view> -->
						<view  v-if='item.auditStatus===0' class="editBtn c-flex jc-center c-item-center" @tap.stop="checkHandler(item)">
							<image  :src="remoteImgUserUrl+'check.png'"></image>审核
						</view>
						
					</view>
				</view>
			</view>
		</scroll-view>
		<view class="submit_btn c-flex jc-between">
			
			<view class="submit c-flex jc-center c-item-center" @tap="add()"><text>+</text> 新增用户信息</view>
			
		</view>
	</view>
</template>

<script>
	
	export default {
		
		data() {
			return {
				remoteImgUrl: this.$API.IMG_URL + '/construct-supervision-mp/',
				remoteImgUserUrl: this.$API.IMG_URL + '/gas/yehuaqi/',
				imgUserUrl: this.$API.IMG_URL + '/liquefied-mall/common/',
				
				list:[],
				limit: 10,
				page: 1,
				total: 0,
				loadStatus: 'more', 
				isLoadMore:false,
				lpgUserName:''
			};
		},
		onLoad() {
			uni.setNavigationBarColor({
				backgroundColor:'#f9ead5',
				frontColor: '#000000'
			});
			
		},
		onShow() {
			this.page=1;
			this.initData()
		},
		methods:{
			checkImg(item){
				if(item.auditStatus===0){
					return this.imgUserUrl +'checking.png'
				}else if(item.auditStatus===1){
					return this.imgUserUrl +'check-pass.png'
				}else if(item.auditStatus===2){
					return this.imgUserUrl +'check-fail.png'
				}
			},
			checkHandler(item){
				uni.navigateTo({
					url:'./check?id='+item.id
				})
			},
			add(item){
				uni.navigateTo({
					url:'./add-user'
				})
			},
			detailHandler(item){
				uni.navigateTo({
					url:'./detail?item='+JSON.stringify(item)
				})
			},
			edit(item){
				uni.navigateTo({
					url:'./add-user?item='+JSON.stringify(item)+'&type=edit'
				})
			},
			
			
			lower(){
				if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
					if (this.total > (this.limit * this.page)) {
						this.isLoadMore = true;
						this.page += 1
							this.initData();	
						}
				}
			},
			onInputChange(){
				this.page =1;
				this.initData();
			},
			initData(){
				uni.showLoading();
				this.loadStatus = 'loading'
				const params = {page:this.page,limit:this.limit,name:this.lpgUserName || ''};
				this.$API.liquefiedGasRoomUserList(params).then(res =>{
						uni.hideLoading();
						if (this.page !== 1) {
							this.list = this.list.concat(res.page.list || [])
						} else {
							this.list = res.page.list || [];
						}
						this.total = res.page.totalCount;
						uni.stopPullDownRefresh(); //关闭加载动画
						if (this.list.length == this.total) { //判断接口返回数据量小于请求数据量，则表示此为最后一页
							this.isLoadMore = true
							this.loadStatus = 'nomore'
						} else {
							this.isLoadMore = false
						}
				}).catch(()=>{
					//联网失败, 结束加载
					
				});
			},
			getFirstSubstr(str) {
				if (str) {
					return str.substr(0, 1)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.room-check-page{
		position: relative;
		background-image: linear-gradient(rgba(249, 195, 115, .3) 0%, #F9F9F9 100%);
		height: 100%;
		.checkImg{
			width: 196rpx;
			height: 150rpx;
			position: absolute;
			top:35rpx;
			right: 10rpx;
		}
		.search-con{
			border-radius: 18rpx;padding: 20rpx 18rpx 0;
			.input-con{
				position: relative;width: 695rpx;border: 2rpx solid rgba(255, 154, 22, 1);
				height: 80rpx;line-height: 80rpx;padding-left: 18rpx;background: #ffffff;border-radius: 16rpx;font-size: 24rpx;
				.line{
					height: 40rpx;border: 2rpx solid rgba(255, 154, 22, 1);position: absolute;right: 115rpx;
				}
				text{
					font-size: 28rpx;font-family: PingFang-SC-Medium, PingFang-SC;
					font-weight: 500;color: #3E3E3E;line-height: 40rpx;position: absolute;right: 38rpx;
				}
			}
			/*修改提示文字的颜色*/
			input::-webkit-input-placeholder {color: #8B959F;}
			input:-moz-placeholder {color: #8B959F;}
			input::-moz-placeholder { color: #8B959F;}
			input:-ms-input-placeholder { color: #8B959F;}
			
		}
		
		.p-list{
			margin: 20rpx 18rpx 0;
			.p-l-item{
				background: #FFFFFF;border-radius: 18rpx;padding: 15rpx 28rpx 20rpx;margin-bottom:20rpx;position:relative;
				.p-content {
					margin: 25rpx 0 10rpx;
				
					.p-c-item {
						font-family: PingFang-SC, PingFang-SC;font-weight: 500;font-size: 26rpx;margin-bottom: 24rpx;
						text:first-child{
							
							color: #8B959F;
						}
						text:last-child{
							color: #333333;
							width: 510rpx;
						}

					}	
				}
				.c_title {
					font-family: PingFangSC-Semibold, PingFang SC;
					padding: 15rpx 0 14rpx 0rpx;
					position: relative;
					.c-pos-r{
						position: absolute;
						right: 10rpx;
						top: 40rpx;
						.checkStatus{
							width:50rpx;height: 50rpx;
							
						}
						
					}
					
					.circle_first_char{
						
						line-height: 92rpx;text-align: center;width: 92rpx;height: 92rpx;background: rgba(232,103,72,0.07);border-radius: 46rpx;border: 2rpx solid #E86748;font-family: PingFangSC, PingFang SC;font-weight: 600;font-size: 40rpx;color: #E86748;
										
						image {
							width: 68rpx;
							height: 68rpx;
						}
					}
				
				
					.c_title_type {
						padding-left: 24rpx;
						padding-top: 10rpx;
				
						.name {
							font-family: PingFang-SC, PingFang-SC;font-weight: 800;font-size: 30rpx;color: #333333;
						}
				
						.time {
							margin-top: 8rpx;font-family: PingFang-SC, PingFang-SC;font-weight: 400;font-size: 26rpx;color: #8B959F;
						}
					}
				}
				
			}
		}
		.editBtn{
			//margin-right: 40rpx;
			width: 160rpx;
			height: 74rpx;
			border-radius: 16rpx;
			border: 2rpx solid #DEDFDF;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: 500;
			font-size: 26rpx;
			color: #3E3E3E;
			line-height: 74rpx;
			text-align: center;
			image{
				width: 38rpx;
				height: 38rpx;
				margin-right: 10rpx;
			}
		}
		.submit_btn {
			    margin: 50rpx auto;
			    width: 710rpx;
			    height: 84rpx;
			.submit {
				text{
				    margin-right: 10rpx;font-size: 60rpx;font-weight: bold;margin-top: -9rpx;
				}
				width: 100%;background: linear-gradient( 180deg, #F18858 0%, #E86547 100%);border-radius: 16rpx;border: 2rpx solid #E96949;line-height: 84rpx;text-align: center;font-family: PingFang-SC, PingFang-SC;font-weight: 500;font-size: 28rpx;color: #FFFFFF;
			}
			// .submit::first-letter {
			//   font-size: 60rpx; /* 使第一个字符的字体大小为正常字体的两倍 */
			//   font-weight: bold; /* 将第一个字符设置为粗体 */
			 
			// }
		}
	}
	
</style>
